package com.arm.system.service.impl;

import java.util.List;

import com.arm.common.constant.UserConstants;
import com.arm.common.core.domain.entity.SysUser;
import com.arm.common.utils.DateUtils;
import com.arm.common.utils.StringUtils;
import com.arm.system.domain.ArmInventory;
import com.arm.system.mapper.ArmInventoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.arm.system.service.IArmInventoryService;

/**
 * 库存管理模块Service业务层处理
 * 
 * @author arm
 * @date 2023-11-06
 */
@Service
public class ArmInventoryServiceImpl implements IArmInventoryService 
{
    @Autowired
    private ArmInventoryMapper armInventoryMapper;

    /**
     * 查询库存管理模块
     * 
     * @param id 库存管理模块主键
     * @return 库存管理模块
     */
    @Override
    public ArmInventory selectArmInventoryById(Long id)
    {
        return armInventoryMapper.selectArmInventoryById(id);
    }

    /**
     * 查询库存管理模块列表
     * 
     * @param armInventory 库存管理模块
     * @return 库存管理模块
     */
    @Override
    public List<ArmInventory> selectArmInventoryList(ArmInventory armInventory)
    {
        return armInventoryMapper.selectArmInventoryList(armInventory);
    }

    /**
     * 新增库存管理模块
     * 
     * @param armInventory 库存管理模块
     * @return 结果
     */
    @Override
    public int insertArmInventory(ArmInventory armInventory)
    {
        armInventory.setCreateTime(DateUtils.getNowDate());
        return armInventoryMapper.insertArmInventory(armInventory);
    }

    /**
     * 修改库存管理模块
     * 
     * @param armInventory 库存管理模块
     * @return 结果
     */
    @Override
    public int updateArmInventory(ArmInventory armInventory)
    {
        armInventory.setUpdateTime(DateUtils.getNowDate());
        return armInventoryMapper.updateArmInventory(armInventory);
    }

    /**
     * 批量删除库存管理模块
     * 
     * @param ids 需要删除的库存管理模块主键
     * @return 结果
     */
    @Override
    public int deleteArmInventoryByIds(Long[] ids)
    {
        return armInventoryMapper.deleteArmInventoryByIds(ids);
    }

    /**
     * 删除库存管理模块信息
     * 
     * @param id 库存管理模块主键
     * @return 结果
     */
    @Override
    public int deleteArmInventoryById(Long id)
    {
        return armInventoryMapper.deleteArmInventoryById(id);
    }

    /**
     * 校验库存是否绑定装备
     *
     * @param id 库存管理模块主键
     * @return 结果
     */
    @Override
    public boolean checkInventoryUnique(Long id)
    {
        ArmInventory info = armInventoryMapper.checkInventoryUnique(id);
        if (StringUtils.isNotNull(info) && info.getId().longValue() != id.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}
